<template>
	<view>
		<header-vue bgColor="transparent" :backOpBg="true">
			<template v-slot:btnLt>
				<view class="flex btn-header">
					<view class="flex">
						<i class="iconfont icon-fenxiang"></i>
					</view>
					<view class="flex" @click="goPage('/views/shop/cart')">
						<i class="iconfont icon-cart font48"></i>
					</view>
				</view>
			</template>
		</header-vue>
		<view class="swiper">
			<u-swiper height="100%" :list="list" @change="e => currentNum = e.current" :autoplay="false"
				:indicatorStyle="{right: '32rpx', bottom: '12rpx'}">
				<view slot="indicator" class="flex indicator-num">
					<text class="indicator-num__text font24">{{ currentNum + 1 }}/{{ list.length }}</text>
				</view>
			</u-swiper>
		</view>
		<view class="detail">
			<view class="white-box">
				<view class="flex between font40">
					<view>团购套餐，限时特惠</view>
					<view class="flex new font24"><i class="iconfont icon-new font24"></i>上新7天</view>
				</view>
				<view class="flex between goods-price">
					<view class="flex price font28">
						<text>￥</text>
						<text class="font36">{{goodInfo.price}}</text>
						<text>.10</text>
						<text class="font20">￥ {{goodInfo.original_price}}</text>
					</view>
					<view class="font24">已售 {{goodInfo.sale_count}}</view>
				</view>
				<view class="flex between progress">
					<view class="progress-bottom">
						<view class="progress-active" :style="{width: '30%'}"></view>
					</view>
					<view class="font24">已抢74%</view>
				</view>
			</view>
			<view class="flex between white-box">
				<view class="font32">{{goodInfo.name}}</view>
				<view class="line"></view>
				<view class="collect font24">
					<i class="iconfont icon-star"></i>
					<view>收藏</view>
				</view>
			</view>
			<view class="flex between white-box font28">
				<view class="flex">
					<view>优惠</view>
					<view class="flex ticket">
						<view>平台券</view>
						<view>19减4</view>
					</view>
					<view class="flex ticket">
						<view>平台券</view>
						<view>19减4</view>
					</view>
				</view>
				<view class="flex get-ticket" @click="goPage('/views/mine/couponCenter')">
					<view class="txt">去领券</view>
					<i class="iconfont icon-jiantou font28"></i>
				</view>
			</view>
			<view class="flex white-box font28 between goods-info" @click="showModal('商品参数', goodsInfo, 'bottom')">
				<i class="iconfont icon-liebie font32"></i>
				<view>
					<view>米粉</view>
					<view class="font24">产品系列</view>
				</view>
				<view class="goods-info-line"></view>
				<view>
					<view>米粉</view>
					<view class="font24">成分特点</view>
				</view>
				<view class="goods-info-line"></view>
				<view>
					<view>米粉</view>
					<view class="font24">口感特色</view>
				</view>
				<view class="goods-info-line"></view>
				<view>
					<view>包装</view>
					<view class="font24">包装种类</view>
				</view>
				<i class="iconfont icon-jiantou font28"></i>
			</view>
			<view class="white-box font28" style="padding: 0 32rpx;">
				<view class="flex between item" @click="showModal('消费须知', tipInfo)">
					<view class="flex">
						<image :src="IMAGE_URL + '/static/shop/yysj.png'"></image>
						<view>营业时间内可用</view>
					</view>
					<i class="iconfont icon-jiantou font28"></i>
				</view>
				<view class="flex between item" @click="showModal('服务保障中', bzInfo)">
					<view class="flex">
						<image :src="IMAGE_URL + '/static/shop/bz.png'"></image>
						<view class="flex">免预约<view class="bz-line"></view>随时退</view>
					</view>
					<i class="iconfont icon-jiantou font28"></i>
				</view>
				<view class="flex between item">
					<view class="flex">
						<image :src="IMAGE_URL + '/static/shop/sjzz.png'"></image>
						<view>商家资质</view>
					</view>
					<i class="iconfont icon-jiantou font28"></i>
				</view>
			</view>
			<view class="white-box font28">
				<view class="flex between font24">
					<view class="flex">
						<view class="font30 fontbold-500 title">评价（10+）</view>
						<view class="comment-good">近一个月好评率高达99%</view>
					</view>
					<view class="flex view-all" @click="goPage('/views/shop/comment')">
						查看全部
						<i class="iconfont icon-jiantou font28"></i>
					</view>
				</view>
				<view v-for="item in 2" class="comment-list">
					<view class="flex start info">
						<image :src="IMAGE_URL + '/static/login/bg.png'" class="avatar"></image>
						<view class="nickname">用户名称</view>
					</view>
					<view>第1次购买这家的牛肉粉，挺好吃的，里面的牛肉担保之也很高，是和养身的人吃，值得回购。</view>
				</view>
			</view>
			<view class="white-box font24">
				<view class="flex between">
					<view class="flex" @click="goPage('/views/shop/store')">
						<image :src="IMAGE_URL + '/static/login/bg.png'" class="cover"></image>
						<view class="flex column between store">
							<view>
								<view class="font32 fontbold-500 store-title">津市牛肉粉</view>
								<view class="flex start star">
									<view v-for="starIndex in 5" class="iconfont icon-starFull font28" style="margin-right: 8rpx;" :style="{color: starIndex < 3 ? '#FF4040' : '#FFD2D2'}"></view>
								</view>
							</view>
							<view class="fans">6999粉丝</view>
						</view>
					</view>
					<view class="flex btn-guanzhu font32">
						<i class="iconfont icon-add font28"></i>
						关注
					</view>
				</view>
				<view class="address font24">
					<view class="flex start">
						<i class="iconfont icon-dingwei font24"></i>
						<view class="ellipsis">距您244m，万福路888号长沙汇金购物中心商城L6层展示一行</view>
					</view>
					<view class="flex start">
						<i class="iconfont icon-clock font24"></i>
						<view>营业中：10:00 - 22:00</view>
					</view>
				</view>
			</view>
			<view class="white-box">
				<view class="font32 fontbold-500">商品详情</view>
			</view>
		</view>
		<view class="flex between fixed">
			<view class="flex start">
				<view class="item font20">
					<i class="iconfont icon-store font40"></i>
					<view>店铺</view>
				</view>
				<view class="item font20">
					<i class="iconfont icon-kefu font40"></i>
					<view>客服</view>
				</view>
				<view class="item font20">
					<i class="iconfont icon-star font40"></i>
					<view>收藏</view>
				</view>
			</view>
			<view class="flex font36 fontbold-500">
				<view class="flex btn-join" @click="addGoods('cart')">加入购物车</view>
				<view class="flex btn-buy" @click="addGoods('buy')">立即购买</view>
			</view>
		</view>
		<modal-vue ref="modal"></modal-vue>
		<cart-modal-vue ref="cartModal"></cart-modal-vue>
	</view>
</template>

<script>
	import headerVue from '@/components/header.vue';
	import modalVue from './components/modal.vue';
	import cartModalVue from './components/cartModal.vue';
	import appConfig from '@/config/app.js'
	import { getGoodInfo } from '@/api/modules/shop.js';
	export default {
		data() {
			return {
				id:'',
				goodInfo:{},
				IMAGE_URL: appConfig.IMAGE_URL,
				list: [],
				currentNum: 0,
				showTip: false,
				tipInfo: [
					{icon: 'icon-clock-full', color: '#DF9824', title: '使用时间', des: ['仅工作日可用，周末、节假日不可以']},
					{icon: 'icon-file', color: '#0785CF', title: '使用规则', des: ['1.堂食餐前外带均可', '2.如部分菜品因时令或售罄等其他不可抗因素无法提供，请联系商家协调处理，感谢您的理解', '3.无需预约，消费高峰期可能需等位']},
				],
				bzInfo: [
					{icon: 'icon-hudun', color: '#0785CF', title: '七天无理由退货', des: ['满足相应条件（未使用、未拆包）时，消费者可申请“7天无理由退货”']},
					{icon: 'icon-hudun', color: '#0785CF', title: '退货宝', des: ['满足相应条件（未使用、未拆包）时，消费者可申请“7天无理由退货”']},
				],
				goodsInfo: [
					{ title: '产品系列', des: '米粉' },
					{ title: '成分特点', des: '米粉' },
					{ title: '口感特色', des: '米粉' },
				]
			}
		},
		components: {
			headerVue,
			modalVue,
			cartModalVue
		},
		mounted() {

		},
		onLoad(options) {
			console.log(options);
			this.id = options.id
			getGoodInfo({i:3,do:'goods.detail',id:this.id}).then(res=>{
				console.log(res);
				this.goodInfo = res.data
			})
		},
		methods: {
			showModal(title, list, mode) {
				this.$refs.modal.open(title, list, mode)
			},
			addGoods(type, info) {
				this.$refs.cartModal.open(type, info)
			},
			goPage(url) {
			    uni.navigateTo({ url });
			},
		}
	}
</script>

<style lang="scss" scoped>
	.btn-header .flex {
		width: 48rpx;
		height: 48rpx;
		background: rgba(0, 0, 0, 0.2);
		border-radius: 50%;
		color: $uni-text-color-inverse;
		margin-left: 20rpx;
	}

	.swiper {
		position: absolute;
		top: 0;
		width: 100%;
		height: 640rpx;
		z-index: -1;

		.indicator-num {
			width: 54rpx;
			height: 30rpx;
			background: rgba(0, 0, 0, 0.2);
			border-radius: 4rpx;
			color: $uni-text-color-inverse;
		}
	}

	.detail {
		background: #F6F6F6;
		position: absolute;
		top: 640rpx;
		width: 100%;
		padding-bottom: calc(env(safe-area-inset-bottom) + 88rpx);

		.white-box {
			padding: 28rpx 32rpx;
			box-sizing: border-box;
			background: $uni-bg-color;
			margin-bottom: 20rpx;
			
			.new {
				width: 134rpx;
				height: 44rpx;
				background: #FF4141;
				border-radius: 20rpx;
				color: $uni-text-color-inverse !important;
				
				.iconfont {
					margin-right: 4rpx;
					color: #F0FA60;
				}
			}

			.goods-price {
				margin: 16rpx 0 28rpx 0;
			}
			
			.icon-liebie {
				margin-right: 26rpx;
			}
			
			.goods-info-line {
				height: 60rpx;
				width: 2rpx;
				background: #DDDDDD;
				margin: 0 16rpx;
			}

			.price {
				height: 48rpx;
				border-radius: 10rpx;
				color: $uni-text-color-red;
				align-items: baseline;
				font-weight: 500;

				.font20 {
					color: $uni-text-color-grey;
					text-decoration-line: line-through;
					margin-left: 4rpx;
				}
			}

			.font24 {
				color: $uni-text-color-grey;
			}

			.progress {
				height: 64rpx;
				background: #FFF2F2;
				border-radius: 16rpx;
				padding: 16rpx 20rpx;
				box-sizing: border-box;
				color: #FF4141;

				.progress-bottom {
					background: $uni-bg-color;
					height: 28rpx;
					border-radius: 20rpx;
					width: 360rpx;
				}

				.progress-active {
					background: linear-gradient(90deg, #FF6E6E 0%, #FF4141 100%);
					height: 100%;
					border-radius: 20rpx;
				}
			}

			.line {
				height: 72rpx;
				width: 2rpx;
				border-left: 1rpx dashed $uni-text-color-grey;
				margin: 0 40rpx;
			}

			.collect {
				flex-shrink: 0;

				.iconfont {
					font-size: 44rpx;
				}
			}

			.ticket {
				margin-left: 28rpx;

				view:nth-child(1) {
					padding: 4rpx 8rpx;
					box-sizing: border-box;
					height: 46rpx;
					background: #FF4040;
					border-radius: 8rpx 4rpx 4rpx 8rpx;
					color: $uni-text-color-inverse;
				}

				view:nth-child(2) {
					padding: 4rpx 8rpx;
					height: 46rpx;
					box-sizing: border-box;
					border-radius: 4rpx 8rpx 8rpx 4rpx;
					border: 1rpx solid #FF4040;
				}
			}

			.get-ticket {

				.txt {
					color: #DF9824;
					margin-right: 8rpx;
				}
			}

			.item {
				border-top: 1rpx solid #DDDDDD;
				padding: 28rpx 0;

				&:nth-child(1) {
					border: 0;
				}

				image {
					width: 28rpx;
					height: 28rpx;
					margin-right: 8rpx;
				}

				.bz-line {
					margin: 0 12rpx;
					height: 24rpx;
					background: #DDDDDD;
					width: 1rpx;
				}
			}

			.title {
				color: $uni-text-color;
			}

			.comment-good {
				color: $uni-text-color-grey;
			}

			.view-all {
				color: #DF9824;

				.iconfont {
					margin-left: 4rpx;
				}
			}

			.comment-list {
				margin-top: 28rpx;

				.avatar {
					width: 64rpx;
					height: 64rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				.info {
					margin-bottom: 20rpx;
					color: $uni-text-color-grey1;
				}
			}

			.cover {
				width: 160rpx;
				height: 160rpx;
				border-radius: 20rpx;
				margin-right: 20rpx;
				flex-shrink: 0;
			}

			.store {
				height: 160rpx;
				align-items: flex-start;
				width: 100%;
			}

			.store-title {
				margin-bottom: 12rpx;
			}

			.fans {
				color: $uni-text-color-grey;
			}

			.btn-guanzhu {
				width: 152rpx;
				height: 58rpx;
				background: #DF9824;
				box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(223, 152, 36, 0.08);
				border-radius: 60rpx;
				color: $uni-text-color-inverse;

				.icon-add {
					margin-right: 4rpx;
				}
			}

			.address {
				border-top: 1rpx solid #DDDDDD;
				margin-top: 20rpx;
				color: $uni-text-color-grey1;

				.iconfont {
					margin-right: 8rpx;
					color: #DF9824;
				}

				.flex {
					margin-top: 20rpx;
				}
			}
		}
	}

	.fixed {
		position: fixed;
		width: 100%;
		height: 88rpx;
		background: $uni-bg-color;
		padding: 0 32rpx;
		box-sizing: border-box;
		bottom: env(safe-area-inset-bottom);
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);

		.item {
			margin-right: 24rpx;
		}

		.btn-buy,
		.btn-join {
			width: 228rpx;
			height: 76rpx;
			border-radius: 60rpx;
			color: $uni-text-color-inverse;
		}

		.btn-buy {
			background: linear-gradient(90deg, #0785CF 0%, #25A4EF 100%);
			box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(7, 133, 207, 0.1);
		}

		.btn-join {
			margin-right: 20rpx;
			background: linear-gradient(90deg, #DF9824 0%, #F4B042 100%);
			box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(223, 152, 36, 0.1);
		}
	}
</style>